package org.springframework.security.web.util.matcher;

import jakarta.servlet.http.HttpServletRequest;

/**
 * @author Dillon
 * @date 2024/7/4
 * @slogan 致敬大师 致敬未来的你
 * @desc 请求匹配器，定义所有请求都能匹配上
 */
public final class AnyRequestMatcher implements RequestMatcher {

	/**
	 * 单例对象
	 */
	public static final RequestMatcher INSTANCE = new AnyRequestMatcher();

	/**
	 * 私有构造
	 */
	private AnyRequestMatcher() {
	}

	/**
	 * 匹配规则 ，恒等能匹配上
	 *
	 * @param request 请求对象
	 * @return 匹配结果
	 */
	@Override
	public boolean matches(HttpServletRequest request) {
		return true;
	}

	/**
	 * equals
	 *
	 * @param obj 待比较对象
	 * @return 是否相同
	 */
	@Override
	@SuppressWarnings("deprecation")
	public boolean equals(Object obj) {
		return obj instanceof AnyRequestMatcher
				|| obj instanceof org.springframework.security.web.util.matcher.AnyRequestMatcher;
	}

	/**
	 * hashcode
	 *
	 * @return hashcode 值
	 */
	@Override
	public int hashCode() {
		return 1;
	}

	/**
	 * 序列化字符串
	 *
	 * @return
	 */
	@Override
	public String toString() {
		return "any request";
	}

}
